import SysUtil from './utils/SysUtil'
import { netInfo } from './network'

/**
 * 设置数据
 * @param data
 * @param setNetInf
 * @param setRTime
 * @returns {function(): void}
 */
const setDatas = (setNetInf, setRTime) => {
  const interval = setInterval(
    (function target() {
      const { getData } = window.api.data
      const { runningTime } = getData()
      setRTime(runningTime)

      setTimeout(() => {
        const { netInf } = getData()
        setNetInf(netInf)
      }, 1000)

      return target
    })(),
    1000
  )

  return () => {
    clearInterval(interval)
  }
}

export { setDatas }
